<template>
	<view class="tabbar">
		<scroll-view class="scroll" scroll-x="true" show-scrollbar='false'>
			<view class="list">
				<block v-for="(item,index) of list" :key='index'>
					<view :class="['item',{'active':ind==index}]" @tap="tabClick(item.id)">
						{{item.text}}
					</view>
				</block>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				ind:0
			}
		},
		props:{
			list:{
				type:Array,
				default:()=>{
					return []
				}
			},
			active:{
				type:Number,
				default:()=>{
					return 0
				}
			}
		},
		methods:{
			tabClick(index){
				this.ind=index
				this.$emit('update:active',index)
			}
		},
		watch:{
			active(news){
				this.ind=news
			}
		}
	}
</script>

<style>
.tabbar{
	position: sticky;
	z-index: 999;
	top: 0;
	background: #fff;
	width: 100%;
	height: 88rpx;
	overflow: hidden;
}
.scroll{
	width: 100%;
	height: 100%;
}
.scroll .list{
	white-space:nowrap
}
.scroll .list .item{
	padding: 25rpx 40rpx;
	font-size: 28rpx;
	font-weight: 700;
	color: #939393;
	display: inline-block;
	position: relative;
	transition: all .3s;
	
}
.scroll .list .item.active{
	color: #000;
}
.scroll .list .item::after{
	content: '';
	position: absolute;
	width: 66rpx;
	height: 10rpx;
	bottom: 18rpx;
	border-radius: 5rpx;
	left: 50%;
	transform: translateX(-50%);
	background:transparent;
	transition: all .3s;
}
.scroll .list .item.active::after{
	background: #fede33;
}
</style>
